﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Frame.Lib.Data;
using Frame.Lib.Web;
using Frame.Lib.Common;
using Frame.Lib.Core.Cache;

namespace Frame.Lib.Core.Base
{
    public class BaseDAL
    {
        private DBHelper _dbHelper;

        public virtual DBHelper dbOper
        {
            get
            {
                return _dbHelper;
            }
            set
            {
                _dbHelper = value;
            }

        }

        //protected static string DBSchema
        //{
        //    get
        //    {                
        //        return AppSetting.DBSchema;                
        //    }
        //}

        //public BaseDAL(DBHelper dbHelper)
        //{
        //    _dbHelper = dbHelper;
        //}

        public BaseDAL()
        {
            if (AppSetting.MultiCompany == true)
            {
                string connectionString = "";
                if (!string.IsNullOrEmpty(AppSession.CompanyLoginName) && CacheManager.Instance.CompanyContainer.ConnectionStrings.ContainsKey(AppSession.CompanyID))
                {
                    connectionString = CacheManager.Instance.CompanyContainer.ConnectionStrings[AppSession.CompanyID];
                }
                _dbHelper = DBHelper.Instance(connectionString);
            }
            else
            {
                _dbHelper = DBHelper.Instance();
            }
        }

        protected string GetPagerSql(PagerSetting pager, string select)
        {
            return select;
        }

    }
}
